#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<cstdio>
using namespace std;
int n, id, h, m, cur, sum;
int arr[1010], tim[1010];
char type, temp;
int main()
{
    cin >> n;
    for (int day = 0;day < n;)
    {
        cin >> id >> type >> h >> temp >> m;
        if (id == 0)
        {
            if (cur == 0)
                cout << 0 << " " << 0 << '\n';
            else
                cout << cur << " " << (int)(sum * 1.0 / cur + 0.5) << '\n';
            day++;
            cur = sum = 0;
            memset(arr, 0, sizeof arr);
        }
        else if (type == 'S')
        {
            arr[id] = 1;
            tim[id] = h * 60 + m;
        }
        else if (type == 'E' && arr[id])
        {
            arr[id] = 0;
            sum += h * 60 + m - tim[id];
            cur++;
        }
    }
    return 0;
}